package 优先算法.位运算.两整数之和;

/**
 * https://leetcode.cn/problems/sum-of-two-integers/description/
 */
public class Main {
    public static void main(String[] args) {
        Solution so = new Solution();
        int a = 1,b = 2;
        int rel = so.getSum(a, b);
        System.out.println(rel);
    }
}
class Solution {
    //异或运算-无进位相加
    public int getSum(int a, int b) {
        while( b != 0){
            int temp = a ^ b;//无进位相加

            b = (a & b) << 1;//求二进制 进位 直到进位为0

            a = temp;
        }
        return a;
    }
}